home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part2 / 11377 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.4 KB

  1. Path: erich.triumf.ca!bennett
  2. From: bennett@erich.triumf.ca (P.Bennett)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: Float to String
  5. Date: 23 Mar 1996 09:37 PST
  6. Organization: TRIUMF: Tri-University Meson Facility
  7. Distribution: world
  8. Message-ID: <23MAR199609371746@erich.triumf.ca>
  9. References: <4is29s$h1a@dfw-ixnews6.ix.netcom.com> <4j0m8a$1mem@darkwing.cadvision.com>
  10. NNTP-Posting-Host: ftp.triumf.ca
  11. News-Software: VAX/VMS VNEWS 1.50    
  12.  
  13. In article <4j0m8a$1mem@darkwing.cadvision.com>, douglasd@cadvision.com (Doran Douglas) writes...
  14. >scoshe@ix.netcom.com(Christopher Scott Shelton ) wrote:
  15. >>Is it possible to convert a float to a string?  like the itoa function.
  16. >try strcpy 'ing the float to a string array
  17. >eg strcpy(string, float_variable_name);
  18.  
  19. WHAT!!!!!
  20.  
  21. This is highly unlikely to do anything useful.  It will more likely do
  22. something _extremely_ unpleasant.   strcpy() will copy bytes from the float
  23. into the string, until it finds a zero byte.  It _will_ _not_ convert the float
  24. to a readable string.
  25.  
  26. Use sprintf()
  27.  
  28. Peter Bennett VE7CEI                | Vessels shall be deemed to be in sight
  29. Internet: bennett@triumf.ca         | of one another only when one can be
  30. Packet: ve7cei@ve7kit.#vanc.bc.ca   | observed visually from the other
  31. TRIUMF, Vancouver, B.C., Canada     |                          ColRegs 3(k)
  32. GPS and NMEA info and programs: ftp://sundae.triumf.ca/pub/peter/index.html
  33. or: ftp://ftp-i2.informatik.rwth-aachen.de/pub/arnd/GPS/peter/index.html
  34.  
  35.